﻿namespace Sidvall.IdentityManager.Net.SimpleServices.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class Plugin : global::Sidvall.Data.SimpleServiceDataRowBase, global::Sidvall.IdentityManager.Data.IPlugin
    {
        #region Public Members

        #region Context

        private string _Context;
        public string Context
        {
            get
            {
                return _Context;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_Context, value))
                    return;
                _Context = value;
                OnPropertyChanged(nameof(Context), true);
            }
        }

        #endregion
        #region EditIsEnabled

        private bool _EditIsEnabled;
        public bool EditIsEnabled
        {
            get
            {
                return _EditIsEnabled;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_EditIsEnabled, value))
                    return;
                _EditIsEnabled = value;
                OnPropertyChanged(nameof(EditIsEnabled), true);
            }
        }

        #endregion
        #region FilterIsEnabled

        private bool _FilterIsEnabled;
        public bool FilterIsEnabled
        {
            get
            {
                return _FilterIsEnabled;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_FilterIsEnabled, value))
                    return;
                _FilterIsEnabled = value;
                OnPropertyChanged(nameof(FilterIsEnabled), true);
            }
        }

        #endregion
        #region PluginId

        private System.Nullable<int> _PluginId;
        public System.Nullable<int> PluginId
        {
            get
            {
                return _PluginId;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_PluginId, value))
                    return;
                _PluginId = value;
                OnPropertyChanged(nameof(PluginId), true);
            }
        }

        #endregion
        #region ServerItemId

        private int _ServerItemId;
        public int ServerItemId
        {
            get
            {
                return _ServerItemId;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_ServerItemId, value))
                    return;
                _ServerItemId = value;
                OnPropertyChanged(nameof(ServerItemId), true);
            }
        }

        #endregion
        #region TypeName

        private string _TypeName;
        public string TypeName
        {
            get
            {
                return _TypeName;
            }
            set
            {
                if (Sidvall.Business.ValidationManager.IsEqual(_TypeName, value))
                    return;
                _TypeName = value;
                OnPropertyChanged(nameof(TypeName), true);
            }
        }

        #endregion
        
        public ServerItem ServerItem { get; set; }
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.LoadInstanceField(this, fieldName, value, cascade, false, false);
        }

        #endregion
        #region Copy

        public Plugin Copy()
        {
            return global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.Copy(this);
        }
        public Plugin Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.IdentityManager.Data.IPlugin item)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.Import(this, item);
        }
        public void Import(global::Sidvall.IdentityManager.Data.IPlugin item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.Import(this, item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.Initialize(this, settings);
        }

        #endregion

        #region IPlugin Members

        string global::Sidvall.IdentityManager.Data.IPlugin.Context
        {
            get
            {
                return this._Context;
            }
            set
            {
                this._Context = value;
            }
        }
        bool global::Sidvall.IdentityManager.Data.IPlugin.EditIsEnabled
        {
            get
            {
                return this._EditIsEnabled;
            }
            set
            {
                this._EditIsEnabled = value;
            }
        }
        bool global::Sidvall.IdentityManager.Data.IPlugin.FilterIsEnabled
        {
            get
            {
                return this._FilterIsEnabled;
            }
            set
            {
                this._FilterIsEnabled = value;
            }
        }
        System.Nullable<int> global::Sidvall.IdentityManager.Data.IPlugin.PluginId
        {
            get
            {
                return this._PluginId;
            }
            set
            {
                this._PluginId = value;
            }
        }
        int global::Sidvall.IdentityManager.Data.IPlugin.ServerItemId
        {
            get
            {
                return this._ServerItemId;
            }
            set
            {
                this._ServerItemId = value;
            }
        }
        string global::Sidvall.IdentityManager.Data.IPlugin.TypeName
        {
            get
            {
                return this._TypeName;
            }
            set
            {
                this._TypeName = value;
            }
        }
        global::Sidvall.IdentityManager.Data.IServerItem global::Sidvall.IdentityManager.Data.IPlugin.ServerItem
        {
            get
            {
                return this.ServerItem;
            }
            set
            {
                this.ServerItem = (ServerItem)value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public Plugin()
        {
        }
        public Plugin(bool initializeDefaultValues)
        {
            if (initializeDefaultValues)
                global::Sidvall.IdentityManager.SystemContextConfig.Current.EntityFacade.PluginManager.Initialize(this);
        }

        #endregion
    }
}